import "./ToolBar.scss"
import render from "@u/render"
const data = [
    { text: '手机App', icon: 'shouji' },
    { text: '个人中心', icon: 'gerenzhongxin' },
    { text: '售后服务', icon: 'wodeshouhou' },
    { text: '人工客服', icon: 'shouhoufuwu' },
    { text: '购物车', icon: 'gouwuche' },
]

export default (() => {

    let toolBar = document.createElement("div")
    toolBar.classList.add("tool-bar", "fixed")

    toolBar.innerHTML = render(
        {
            data
        },
        {
            data: data => data.map((i, n) => `<li><i class="iconfont icon-${i.icon}"></i><span>${i.text}</span>${n === 0 ? '<div class="code"><img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/78c30d4f259ed43ab20e810a522a6249.png"></img><span>扫码领取新人百元礼包</span></div>' : ''}</li>`).join("")
        },
        `
            {{data}}
            <li><i class="iconfont icon-huidingbu"></i><span>回顶部</span></li>
        `
    )


    toolBar.lastElementChild.addEventListener("click", function (e) {
        window.scrollTo(0, 0);
    })

    return toolBar
})()